package club.emergency.wechat.department_staff.operate.consumer.service.fallback_factory;

import club.emergency.wechat.common.response.ResponseEntity;
import club.emergency.wechat.common.response.StatusCode;
import club.emergency.wechat.department_staff.operate.consumer.service.DepartmentStaffOperateConsumer;
import club.emergency.wechat.model.staff.DepartmentStaff;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * Create with IntelliJ IDEA
 * Project Name: wechat
 * Package Name: club.emergency.wechat.department_staff.operate.consumer.service.fallback_factory
 * Date: 2019/4/1
 *
 * @author: 快乐的小菌菌
 * Description:
 */
@Component
public class DepartmentStaffFallbackFactory implements FallbackFactory<DepartmentStaffOperateConsumer> {

    @Override
    public DepartmentStaffOperateConsumer create(Throwable throwable) {
        return new DepartmentStaffOperateConsumer() {
            @Override
            public String saveDepartmentStaff(DepartmentStaff departmentStaff) {
                return ResponseEntity.error(StatusCode.DB_SAVE_ERROR, "新增企业人员失败！", throwable.getMessage());
            }

            @Override
            public String modifyDepartmentStaff(DepartmentStaff departmentStaff) {
                return ResponseEntity.error(StatusCode.DB_SAVE_ERROR, "修改企业人员信息失败！", throwable.getMessage());
            }

            @Override
            public String saveDepartmentStaffFromExcel(String suffix, byte[] bytes, Long departmentId, String departmentCode) {
                return ResponseEntity.error(StatusCode.DB_SAVE_ERROR, "从Excel中导入企业人员失败！", throwable.getMessage());
            }
        };
    }
}
